Skip to content

Reuse copy buffers in OCaml rewatch - #8869

Merged
cknitt merged 1 commit into
masterfrom
reuse-copy-buffers
Oct 16, 2026
Merged

cknitt merged 1 commit into
masterfrom
reuse-copy-buffers

Conversation

@cknitt

@cknitt cknitt commented Oct 15, 2026

Copy link
Copy Markdown
Member

OCaml rewatch allocated a fresh 64 KiB buffer for every file it published (.cmi, .cmj, .cmt, ASTs, sources), and two more for every same-sized .cmi it compared. An allocation profile (Gc.Memprof) of a clean tests/tests build showed these buffers as the largest single source of allocation: 17.5% of all words. Blocks that size go straight to the major heap, so they also drive major-GC work, which with several domains stops all of them.

Each domain now keeps one copy buffer and one comparison buffer and reuses them.

Clean builds of tests/tests without string_unicode_test (see #8866), idle Linux VM with 10 cores, median of 7 interleaved runs:

Before After
Allocated words 241M 198.5M (−18%)
Wall, 1 domain 1.312 s 1.246 s (−5%)
Wall, 8 domains 0.422 s 0.370 s (−12%)

🤖 Generated with Claude Code

Fresh 64 KiB buffers per copied file were the largest single source of
allocation in a build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WZbCuRQ1Tn31bnKzLj5e72
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the reuse-copy-buffers branch from dd71607 to d9d9d32 Compare October 15, 2026 18:42
@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8869

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8869

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8869

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8869

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8869

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8869

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8869

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8869

commit: d9d9d32

@github-actions

Copy link
Copy Markdown

@cknitt
cknitt marked this pull request as ready for review October 16, 2026 04:42
@cknitt

cknitt commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T04:44:32.472364Z d9d9d32 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: d9d9d3292c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cknitt
cknitt requested a review from cristianoc October 16, 2026 04:45

@cristianoc cristianoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic. Should we also explore 0xcaml?

@cknitt

cknitt commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Fantastic. Should we also explore 0xcaml?

The problem with OxCaml is Windows support.

@cknitt
cknitt merged commit dcc7e35 into master Oct 16, 2026
26 checks passed
@cknitt
cknitt deleted the reuse-copy-buffers branch October 16, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants